//部门开放数据TOP10 Box02 
$(function ($) {
	var myChart = echarts.init(document.getElementById('DataBox02_Data'));
	var option = {
		tooltip: {
			trigger: 'axis',
			axisPointer: {
				type: 'shadow'
			}
		},
		grid: {
			right: 20,
			left:20,
			bottom: 0,
			top: 0,
			containLabel: true
		},
		xAxis: [{
			type: 'value',
			axisLine: {
				show: false
			},
			axisTick: {
				show: false
			},
			axisLabel: {
				show: false
			},
			splitLine: {
				show: false
			},
			
		}],
		yAxis: [{
			type: 'category',
			axisLine: {
				show: false
			},
			axisTick: {
				show: false
			},
			splitLine: {
				show: false
			},
			inverse:true,
			axisLabel: {
				margin: 50,
				textStyle: {
					color: '#dbe9fc',
					fontFamily: 'Microsoft Yahei',
					fontSize: 12,
				}
			},
			
			//开放数据部门数
			data : (function(){
	            var arr=[];
	            $.ajax({
	            	method: 'GET',
	                 async : false, //同步执行
	                 url : DataOpen.apiHostName + '/dataopen/statistics/organization/top',
	                 data : {topNum:10,order:3},
	                 dataType : "json", //返回数据形式为json
	                 success : function(result) {
	                	 if (result.code == 'success') {
		                	 $.each(result.data, function(index, item) {
		                		 arr.push(item.name);
		                	 })
	                	 }
	                                        
	                },
	               })
	                 return arr;
	              })() ,
	              
		}],
		series: [{
			name: '开放数据',
			type: 'bar',
			itemStyle: {
				normal: {
					show: true,
					shadowBlur: 0,
					shadowOffsetY: 0,
					shadowColor: 'rgba(0, 218, 226, 0.42)',
					barBorderRadius: 20,
					color: new echarts.graphic.LinearGradient(
						1, 1, 0, 0, [{
							offset: 0,
							color: '#07c0ee'
						}, {
							offset: 1,
							color: '#4896ff'
						}]
					),
				}
			},
			barWidth: 10,
			label: { //图形上的文本标签
				normal: {
					show: true,
					position: 'left',
					margin: 20,
					textStyle: {
						color: '#5ba4ff',
						fontStyle: 'normal',
						fontFamily: 'Microsoft Yahei',
						fontSize: 12,
					},
				},
			},
			data : (function(){
	            var arr=[];
	            $.ajax({
	            	 method: 'GET',
	                 async : false, //同步执行
	                 url : DataOpen.apiHostName + '/dataopen/statistics/organization/top',
	                 data : {topNum:10,order:3},
	                 dataType : "json", //返回数据形式为json
	                 success : function(result) {
	                	 if (result.code == 'success') {
		                	 $.each(result.data, function(index, item) {
		                		 arr.push(item.count);
		                	 })
	                	 }
	                                        
	                },
	                    error : function(errorMsg) {
	                        alert("不好意思,图表请求数据失败啦!");
	                         myChart.hideLoading();
	                       }
	               })
	                 return arr;
	              })() ,
		}, ]
	};
	myChart.setOption(option);
})